import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from 'unplugin-vue-components/resolvers';
import {resolve} from 'path'
// https://vitejs.dev/config/
export default defineConfig({
  base:'./',
  plugins: [
    vue(),
    Components({
      resolvers: [VantResolver()],
    }),
  ],
  resolve: {
      alias: {
          "@": resolve(__dirname, 'src'), // 路径别名
          "@c": resolve(__dirname, 'src/components'), // 路径别名
      },
  },
  server:{ //本地服务
    proxy:{   //代理
      '/wzj': {
        target: 'https://www.wzj.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/wzj/, '') //路径重写
        // 不加重写
        //https://m.wzj.com/wzj/proxy/products/${id}?latitude=&longitude=&network_type=wifi
        //加重写
        //https://m.wzj.com/proxy/products/${id}?latitude=&longitude=&network_type=wifi
      },
      '/local': {
        target: 'http://localhost:3003',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/local/, '') //路径重写
      },
      '/joy': {
        target: 'http://m.joyincake.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/joy/, '') //路径重写
      },
      
    }
  },
  build:{
    outDir:'client'
  }
})



